<?php
    class Container_Model extends dl_connect{
        
        function __construct(){
            $this->Connect();
        }
        
        /**
         * Them record cua bang container
         * @param 
         * @return INT
         * */
        public function add($name, $gioithieu, $noidung, $diadiem=null, $sdt =null, $anh = null,
                            $nguon, $catId, $ngayPost, $vido=null, $kinhdo=null){
            $this->ExecuteSQL(
                "INSERT INTO `dulich`.`container` (`ID` , `name` , `gioithieu` , `noidung` ,
                        `diadiem` , `sdt` , `anh` , `nguon` , `cat_id` , `ngaypost` ,
                        `vido` ,  `kinhdo`  )
                    VALUES ( NULL , '{$name}', '{$gioithieu}', '{$noidung}', '{$diadiem}', 
                                '{$sdt}', '{$anh}', '{$nguon}', '{$catId}', '{$ngayPost}', '{$vido}', '{$kinhdo}'
                    )"
            );
            if(mysql_affected_rows($this->con)>0){
                return 1;
            }else{
                return 0;
            }
        }
        
        /**
         * Xoa record trong table container
         * @param $id: ma so bai viet de xoa
         * @return INT
         **/         
        public function delete($id){
            $this->ExecuteSQL("delete from container where ID ={$id}");
            if(mysql_affected_rows($this->con)>0){
                return 1;
            }else{
                return 0;
            }            
        }
        
        /**
         * thay doi thong tin cua 1 record trong bang container
         * @param
         * @retun INT
         * */
        public function edit($name, $gioithieu, $noidung, $diadiem=null, $sdt =null, $anh = null,
                            $nguon, $catId, $ngayPost, $vido=null, $kinhdo=null, $id){
            $this->ExecuteSQL(
                "UPDATE `dulich`.`container` SET `name` = '{$name}', `gioithieu` = '{$gioithieu}',
                        `noidung` = '{$noidung}',`diadiem` = '{$diadiem}', `sdt` = '{$sdt}',
                        `anh` = '{$anh}', `nguon` = '{$nguon}', `cat_id` = '{$catId}', `ngaypost` = '{$ngayPost}',
                        `vido` = '{$vido}', `kinhdo` = '{$kinhdo}' 
                    WHERE `container`.`ID` = {$id}"
            );
            if(mysql_affected_rows($this->con)>0){
                return 1;
            }else{
                return 0;
            }   
        }
         
    }
?>